import zRequest from '../index'
import type { IAccount, ILoginRes, IUserRes } from './type'
import type { IDataType } from '../types'
enum LoginApi {
  UserLogin = '/login',
  LoginUserInfo = '/users/',
  UserMenus = '/role/'
}

export const userLogin = (data: IAccount) => {
  return zRequest.post<IDataType<ILoginRes>>({
    url: LoginApi.UserLogin,
    showLoading: true,
    data
  })
}

export const getUserInfoById = (id: number) => {
  return zRequest.get<IDataType<IUserRes>>({
    url: `${LoginApi.LoginUserInfo}${id}`,
    showLoading: true
  })
}

export const getUserMenusByRoleId = (id: number) => {
  return zRequest.get<IDataType>({
    url: `${LoginApi.UserMenus}${id}/menu`,
    showLoading: true
  })
}
